export default {
	namespaced: true,
	state() {
		// 弹窗倒计时
		return {
			time: 5,
			weekList: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
		}
	},
	mutations: {
		subTime(state) {
			state.time--
		},
		resetTime(state) {
			state.time = 5
		}
	},
	getters: {
		timeList() {
			let list = []
			for (let i = 8; i <= 23; i++) {
				list.push(i)
			}
			list = list.map(i => {
				let start = `${i}:00`
				let end = `${i + 1}:00`

				return { start, end, id: i - 8 }
			})
			return list
		},
		dateList(state) {
			let list = []
			for (let i = 1; i <= 10; i++) {
				let currentDate = new Date()
				// 添加1天
				currentDate.setDate(currentDate.getDate() + i)
				// 获取当前日期的年、月、日
				let currentYear = currentDate.getFullYear()
				let currentMonth = currentDate.getMonth() + 1 // 月份从0开始，因此要加1
				let currentDay = currentDate.getDate()
				const date = currentYear + '-' + currentMonth + '-' + currentDay
				const week = state.weekList[new Date(date).getDay()]
				list.push({
					date: date,
					week: week
				})
			}
			return list
		}
	},
	actions: {}
}
